/*
 * ModelForm.java
 *
 * Copyright (c) 2008 Teamnet. All Rights Reserved.
 *
 * This source file may not be copied, modified or redistributed,
 * in whole or in part, in any form or for any reason, without the express
 * written consent of Teamnet.
 */

package ro.prjmanager.template.form.commons;

import ro.prjmanager.constants.BackendConstants;
import ro.prjmanager.database.model.Table;

/**
 * This class is used to redifine relativeToRootPackage, relativeToRootPath
 * attributes of the ClassFileForm class from it's default constructor
 */
public class ModelForm extends CommonsModuleForm {
    //the current Table ussed in generating files from templates
    private Table table;

    /**
     * Default constructor
     * @param table - the table for that are generating the mappings
     */    
    public ModelForm(Table table) {
        super();
        this.table=table;
        this.relativeToRootPackage = bundle.getString(BackendConstants.APPLICATION_COMMONS_MODEL_RELATIVE_PACKAGE);

        this.relativeToRootPath = this.relativeToRootPackage.indexOf(BackendConstants.PACKAGE_SEPARATOR)>0?
        this.relativeToRootPackage.replace(BackendConstants.PACKAGE_SEPARATOR,
                BackendConstants.PATH_SEPARATOR):this.relativeToRootPackage;
        this.templatePath=bundle.getString(BackendConstants.APPLICATION_COMMON_MODEL_TEMPLATE_PATH) ;
        javaFileName=getTable().getJavaName();

    }

    public ModelForm() {
        this.relativeToRootPackage = bundle.getString(BackendConstants.APPLICATION_COMMONS_MODEL_RELATIVE_PACKAGE);

        this.relativeToRootPath = this.relativeToRootPackage.indexOf(BackendConstants.PACKAGE_SEPARATOR)>0?
        this.relativeToRootPackage.replace(BackendConstants.PACKAGE_SEPARATOR,
                BackendConstants.PATH_SEPARATOR):this.relativeToRootPackage;
    }

    public Table getTable() {
        return table;
    }

    public void setTable(Table table) {
        this.table = table;
    }
}
